<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function btn(){
            //新建XMLHttpRequest对象
            let xml;
            if (window.XMLHttpRequest) {
                xml = new XMLHttpRequest()
            } else {
                xml = new ActiveXObject("Microsoft.XMLHTTP")
            }

            //发送请求
            xml.open("GET", "http://47.104.241.232/api.php?url=http://api.douban.com/v2/movie/top250?start=0&count=50", true);
            xml.send();
            //监听状态变化，执行一个操作
            xml.onreadystatechange = function () {
                if (
                    xml.readyState === 4 && xml.status === 200
                ) {
                    //将XML转换成字符串
                    let msg = xml.responseText;
                    //将字符串转换成json对象
                    msg = JSON.parse(msg);
                    console.log(msg);
                    for (let i = 0; i < msg.length; i++) {
                        let p=document.createElement("p");
                        document.body.appendChild(p);
                        //p.innerHTML=msg.subjects.title[i]
                        p.innerHTML=msg.subjects[i].id
                    }
                }
            }
        }
    </script>
</head>
<body>
 <button id="bt" onclick="btn()">点我</button>
</body>
</html>